//
//  MAPYVPNRequestManager.swift
//  Mars Proxy
//
//  Created by PowerfullClean on 2023/10/18.
//

import UIKit
import Alamofire
import SwiftyJSON
//#if DEBUG
//let mapy_vpn_url = "https://test.marsproxy.link/iPZbB/eNGl/akECN/"
//#else
let mapy_vpn_url = "https://api.marsproxy.link/iPZbB/eNGl/akECN/"
//#endif

let mapy_vpn_dKey = "R09a1yF6LEenh2oK"

typealias MAPYSuccessHandle = (_ response: Any?)->()
typealias MAPYFailurHandle = (_ error: NSError?)->()

class MAPYVPNRequestManager: NSObject {
    func mapy_tbaHeader() -> HTTPHeaders {
        return [
            "LGKM": MAPYCommon.mapy_bundleIdentifier
        ]
    }
    func mapy_requestUrl() -> String {
        return  mapy_vpn_url
    }
    func mapy_requestMethod() -> HTTPMethod {
        return .get
    }
    func mapy_statrRequest(mapy_successBlock:MAPYSuccessHandle? = nil) {
        AF.request(mapy_requestUrl(), method: mapy_requestMethod(), parameters: nil, headers: mapy_tbaHeader()){ mapy_request in
            mapy_request.timeoutInterval = 15
        }.responseString { mapy_response in
            switch mapy_response.result {
            case .failure(_):
                return
            case .success(_):
                break
            }
            guard let mapy_responseString = mapy_response.value else {
                return
            }
            mapy_successBlock?(mapy_responseString)
        }
    }
}

//MARK: - mapy smart 展示
class MAPYVPNApiList1: MAPYVPNRequestManager {
    
}
//MARK: - mapy list 展示
class MAPYVPNApiList2: MAPYVPNRequestManager {
    override func mapy_requestMethod() -> HTTPMethod {
        return .post
    }
}
